package com.example.widget;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

public class ExerciseDetailActivity extends AppCompatActivity implements ExerciseDetailAdapter.OnSelectListener{
    // 用于获取题目并存储
    private int execiseId;
    private List<ExerciseDetail> details;
    private int score = 0;

    // 控件及adapter
    private RecyclerView lvDetails;
    private ExerciseDetailAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_exercise_detail);

        initData();
        initView();
    }

    private void initData() {
        execiseId = getIntent().getIntExtra("id", 0);
        details = new ArrayList<>();

        ExerciseDetail detail = new ExerciseDetail();
        detail.setSubjectId(1);
        detail.setSubject("1.Android安装包文件简称APK，其后缀名是（）。");
        detail.setA(".exe");
        detail.setB(".txt");
        detail.setC(".apk");
        detail.setD(".app");
        detail.setAnswer(3);
        details.add(detail);

        detail = new ExerciseDetail();
        detail.setSubjectId(2);
        detail.setSubject("2.应用程序层是核心应用程序的集合，主要包括（）。");
        detail.setA("活动管理器");
        detail.setB("短信程序");
        detail.setC("音频驱动");
        detail.setD("Dalvik 虚拟机");
        detail.setAnswer(2);
        details.add(detail);
    }

    private void initView() {
        lvDetails = findViewById(R.id.lv_details);
        LinearLayoutManager manager = new LinearLayoutManager(this);
        lvDetails.setLayoutManager(manager);
        adapter = new ExerciseDetailAdapter(details, this);
        lvDetails.setAdapter(adapter);
    }

    @Override
    public void onSelectA(int position, ImageView ivA, ImageView ivB, ImageView ivC, ImageView ivD) {

    }

    @Override
    public void onSelectB(int position, ImageView ivA, ImageView ivB, ImageView ivC, ImageView ivD) {

    }

    @Override
    public void onSelectC(int position, ImageView ivA, ImageView ivB, ImageView ivC, ImageView ivD) {

    }

    @Override
    public void onSelectD(int position, ImageView ivA, ImageView ivB, ImageView ivC, ImageView ivD) {

    }
}